package top.wilsonlv.jaguar.cloud.upms.sdk.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import top.wilsonlv.jaguar.cloud.auth.sdk.spi.SecurityUserService;
import top.wilsonlv.jaguar.cloud.upms.sdk.vo.UserVO;
import top.wilsonlv.jaguar.commons.web.response.JsonResult;
import top.wilsonlv.jaguar.security.model.SecurityUser;


/**
 * @author lvws
 * @since 2021/6/29
 */
@FeignClient(value = "jaguar-upms-server", contextId = "remoteUserService")
public interface RemoteUserService extends SecurityUserService {

    String USER_TYPE = "ADMIN";

    /**
     * 根据用户主体查询用户
     *
     * @param username 用户主体（用户名/手机号/邮箱）
     * @return 用户
     */
    @Override
    @GetMapping("/feign/user/loadUserByUsername")
    JsonResult<SecurityUser> loadUserByUsername(@RequestParam("username") String username);

    /**
     * 根据设备签名认证用户
     *
     * @param deviceUid 设备UID
     * @param userId    用户ID
     * @return 用户
     */
    @Override
    @GetMapping("/feign/user/loadUsersByDeviceUid")
    JsonResult<SecurityUser[]> loadUsersByDeviceUid(@RequestParam("deviceUid") String deviceUid,
                                                    @RequestParam(value = "userId", required = false) Long userId);

    /**
     * 根据用户ID查询用户
     *
     * @param userId             用户ID
     * @param withUserPermission 是否携带用户权限
     * @param withUserFace       是否携带人脸认证图片
     * @return 用户
     */
    @GetMapping("/feign/user/loadUserByUserId")
    JsonResult<UserVO> loadUserByUserId(@RequestParam("userId") Long userId,
                                        @RequestParam(value = "withUserPermission", required = false, defaultValue = "false") Boolean withUserPermission,
                                        @RequestParam(value = "withUserFace", required = false, defaultValue = "false") Boolean withUserFace);

}
